package com.yeci.controller;

import com.yeci.common.AjaxResult;
import com.yeci.common.controller.BaseController;
import com.yeci.common.page.TableDataInfo;
import com.yeci.entity.SysLinks;
import com.yeci.service.SysLinksService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 * @author yeci
 * @since 2021-09-23
 */
@Slf4j
@RestController
@RequestMapping("/links")
public class SysLinksController extends BaseController {

  @Autowired
  private SysLinksService linksService;

  @GetMapping("/list")
  public TableDataInfo list(SysLinks sysLinks){
    List<SysLinks> Links = linksService.selectLinksList(sysLinks);
    return getDataTable(Links);
  }

  @GetMapping("/byId/{id}")
  public AjaxResult byId(@PathVariable("id") String id){
    SysLinks sysLinks = linksService.selectById(id);
    return AjaxResult.success(sysLinks);
  }

  @PostMapping("/insert")
  public AjaxResult insert(@RequestBody SysLinks sysLinks){
    Integer integer = linksService.insertLink(sysLinks);
    return AjaxResult.toAjax(integer);
  }

  @PostMapping("/update")
  public AjaxResult update(@RequestBody SysLinks sysLinks){
    Integer integer = linksService.updateLink(sysLinks);
    return AjaxResult.toAjax(integer);
  }

  @GetMapping("/delete/{id}")
  public AjaxResult delete(@PathVariable("id") String id){
    Integer integer = linksService.deleteLink(id);
    return AjaxResult.toAjax(integer);
  }

}

